#ifndef unigame_LuaManager_h
#define unigame_LuaManager_h

#include "config/Def.h"
#include <map>
#include "LuaScript.h"
#include "ILuaCallback.h"

namespace unigame
{
	class LuaManager
	{
	public:

		static LuaManager* instance()
		{
			if(!m_instance)
			{
				m_instance = uni_new LuaManager();
			}
			return m_instance;
		}

		static void destroy()
		{
			uni_delete(m_instance);
		}

		LuaScript* loadScript(const char* name);
		void unloadScript(const char* name);

		LuaScript* getScript(const char* name);
		LuaScript* getScript(lua_State* ls);

		void unloadAll();

	private:
		LuaManager(){};
		~LuaManager();

		static LuaManager* m_instance;
		std::map<std::string, LuaScript*> m_scripts;
		std::map<lua_State*, LuaScript*> m_states;
	};
}

#endif